#include<iostream>
using namespace std;
class shape
{
    public:
        virtual ~shape(){}
        virtual double perimeter()=0;
        virtual double area() = 0;
};
class circle :public shape
{
    public:
        circle()
        {
            cout <<"输入圆形的半径:";
            cin >>r;
        }
        virtual ~circle(){}
        double perimeter()
        {
            return 2*3.14*r;
        }
        double area()
        {
            return 3.14*r*r;
        }
    private:
        int r;
};
class square :public shape
{
    public:
        square()
        {
            cout <<"输入正方形边长:";
            cin >>len;
        }
        virtual ~square(){}
        double perimeter()
        {
            return 4*len;
        }
        double area()
        {
            return len*len;
        }
    private:
        int len;
};
class rectangle :public shape
{
    public:
        rectangle()
        {
            cout <<"输入长方形长:";
            cin >>length;
            cout<<"输入长方形宽:";
            cin >>wei;
        }
        virtual ~rectangle(){}
        double perimeter()
        {
            return 2*(length+wei);
        }
        double area()
        {
            return length*wei;
        }
    private:
        int length;
        int wei;
};
class triangle :public shape
{
    public:
        triangle()
        {
            cout <<"输入等边三角形边长:";
            cin >>side;
        }
        virtual ~triangle(){}
        double perimeter()
        {
            return 3*side;
        }
        double area()
        {
            return side*side*0.4275;
        }
    private:
        int side;
};
int main()
{
    shape *cri=new circle;
    cout <<"圆形周长:"<<cri->perimeter()<<endl;
    cout <<"圆形面积:"<<cri->area()<<endl;
    
    shape *squ=new square;
    cout <<"正方形周长:"<<squ->perimeter()<<endl;
    cout <<"正方形面积:"<<squ->area()<<endl;

    shape *rec=new rectangle;
    cout <<"长方形周长:"<<rec->perimeter()<<endl;
    cout <<"长方形面积:"<<rec->area()<<endl;

    shape *tri=new triangle;
    cout <<"等边三角形周长:"<<tri->perimeter()<<endl;
    cout <<"等边三角形面积:"<<tri->area()<<endl;
}